/*******************************************************************************
Replication Materials for Blau, Kahn, Brummund, Cook, and Larson-Koester "Is 
There Still Son Preference in the United States?"

Table 3

Date Modified: 10/21/2019

*******************************************************************************/




*-------------------------------------------------------------------------------
                                   *LOAD DATA
*-------------------------------------------------------------------------------
use "$acs\acs_data",clear


*-------------------------------------------------------------------------------
                               *RESTRICT SAMPLE
*-------------------------------------------------------------------------------
keep if nonusbirth == 0 & multi_sample != 1 & mult == 0 & oldc <=12 & ///
	inrange(age,18,40)==1 & nchild18>=1 & nonrkids == 0 & nonusbirth == 0 ///
	& sfrelate == 0 & father_sample != 1 & female == 1 & foster_hh == 0
keep if bothfirmarr == 1
drop if citizen == 1 | marst == 5


*Label Variables
label var igenfert "Total Fertility"
label var ligengdp "Log of GDP"
label var igenscore "Equity Index"
label var chld1 "First Child Girl"
label var igenlfp "Labor Force Part."
label var igensr "Sex Ratio at Birth"

label var girl_lfp "Girl*Labor Force Part."
label var girl_sr "Girl*Sex Ratio at Birth"
label var girl_ggi "Girl*Equity Index"





*-------------------------------------------------------------------------------
                              *REGRESSIONS, FERTILITY
*-------------------------------------------------------------------------------	
local wgt "hhwtnorm"	
local controls "lths scol cold sp_lths sp_scol sp_cold" //leave out: hsdi
local controls "`controls' i.genrace i.sp_genrace i.region i.year age age2 age3" 
local controls "`controls' sp_age sp_age2 sp_age3 `allvars'"
local controls "`controls' yrsusa1 yrsusa2 sp_yrsusa1 sp_yrsusa2 sp_imm"

// SAMPLE
keep if marst == 1

// EQUITY
reg nchild `controls' igenfert ligengdp igenscore chld1 girl_ggi [aw=`wgt'],  cluster(bpldc)
sum nchild if marst == 1 & igenscore != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_R12", replace  excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenscore chld1 girl_ggi) ctitle(Fertility) label nocons nor2 ///
title("Table R12: Effects of Source Country Characteristics on the Probability of Living Without a Father and Fertility,", "Foreign Born Sample and Women in First Marriage")

// LFPR
reg nchild `controls' igenfert ligengdp igenlfp chld1 girl_lfp [aw=`wgt'],  cluster(bpldc)
sum nchild if marst == 1 & igenlfp != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_R12", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenlfp chld1 girl_lfp) ctitle(Fertility) label nocons nor2

// LFPR & SEX RATIO AT BIRTH
reg nchild `controls' igenfert ligengdp igenlfp igensr chld1 girl_lfp girl_sr [aw=`wgt'],  cluster(bpldc)
sum nchild if marst == 1 & igenlfp != . & igensr != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_R12", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenlfp igensr chld1 girl_lfp girl_sr) ctitle(Fertility) label nocons nor2 sortvar(igenfert ligengdp igenlfp igensr igenscore chld1 girl_lfp girl_sr girl_ggi)
 
